<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<%@ include file="/commons/head.jsp" %>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <%@ include file="/commons/left.jsp" %>
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                管理员列表
            </h1>
            <section class="content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                                <div class="input_box col-sm-5 margin">
                                    <form  name="searchForm" id="searchForm"
                                           action="${ctx}/sysManager/listManager" method="get">
                                        <input type="hidden" id="pageNum" name="pageNum" value="1"/>
                                        <input type="hidden" id="length" name="length" value="10"/>
                                        <label style=" float: left; height: 34px; line-height: 34px;">用户名称：</label>
                                        <div class="input" style="float: left;">
                                            <input type="text" class="form-control" name="userName" placeholder="用户名称">
                                        </div>
                                        <div class="input_btn" style=" float: left;">
                                            <input type="submit" class="btn btn-default" value="查询">
                                        </div>
                                    </form>
                                </div>
                                <div class="margin" style="float:right;">
                                    <button type="button" class="btn btn-default" onclick="window.location.href='${ctx}/sysManager/editManager?action=add'"><span
                                            class="glyphicon glyphicon-plus"></span> 新增
                                    </button>
                                </div>
                            </div>
                            <div class="box-body">
                                <table id="example2" class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>用户名</th>
                                        <th>手机号</th>
                                        <th>状态</th>
                                        <th>创建者</th>
                                        <th>创建时间</th>
                                        <th>用户角色</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:choose>
                                        <c:when test="${page.maxRow>0}">
                                            <c:forEach var="item" items="${listManager}" varStatus="vs">
                                                <tr>
                                                    <td>${item.userName}</td>
                                                    <td>${item.mobile}</td>
                                                    <td>
                                                        <c:choose>
                                                            <c:when test="${item.disable == 0}">
                                                                启用
                                                            </c:when>
                                                            <c:when test="${item.disable == 1}">
                                                                禁用
                                                            </c:when>
                                                        </c:choose>
                                                    </td>
                                                    <td>
                                                            ${item.operator}
                                                    </td>
                                                    <td>
                                                        <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${item.createTime}"/>
                                                    </td>
                                                    <td>
                                                            ${item.roleName}
                                                    </td>
                                                    <td>
                                                        <a onclick="window.location.href='${ctx}/sysManager/editManager?action=update&id=${item.id}'">修改</a>
                                                        <c:if test="${item.roleName != '系统管理员'}">
                                                            <em> </em><a onclick="if (confirm('您确定要删除吗？')) del('${item.id}')">删除</a>
                                                        </c:if>
                                                    </td>
                                                </tr>
                                            </c:forEach>
                                        </c:when>
                                    </c:choose>
                                    </tbody>
                                </table>
                                <div><jsp:include page="/commons/pagination.jsp" /></div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </section>
    </div>
    <%@ include file="/commons/script.jsp" %>
    <script type="text/javascript">
        function del(id) {
            $.ajax({
                cache: false,
                type: "post",
                url: "${ctx}/sysManager/deleteManager",
                data: {id: id},
                error: function () {
                    alert("系统异常");
                },
                success: function (data) {
                    if (data == 1) {
                        alert("删除成功");
                    } else {
                        alert("删除失败");
                    }
                    location.reload()
                }
            });
        }
    </script>
</body>
</html>
